﻿
Qfast.add('widgets', { path: "http://i" + ZYCLib.Domain + "/scripts/terminator2.2.min.js", type: "js", requires: ['fx'] });
Qfast(false, 'widgets', function () {
    K.tabs({
        id: 'fsD1',   //焦点图包裹id
        conId: "D1pic1",  //** 大图域包裹id
        tabId: "D1fBt",
        tabTn: "a",
        conCn: '.fcon', //** 大图域配置class
        auto: 1,   //自动播放 1或0
        effect: 'fade',   //效果配置
        eType: 'click', //** 鼠标事件
        pageBt: true,//是否有按钮切换页码
        bns: ['.prev', '.next'],//** 前后按钮配置class
        interval: 5000  //** 停顿时间
    })
})


$('.sclose').click(function () {
    $('.showsort').hide(100);
    $('.stop a').removeClass('hover');
    $('.stop li').removeClass('hover');
});
$(document).click(function (e) {
    //alert(jq(e.target).attr('class'));
    var c = $(e.target).attr('class');
    if (c == "showsort" | c == "stwo" | c == "scon" | c == "stwoa" | c == "hover") { }
    else { $('.showsort').hide(100); $('.stop a').removeClass('hover'); $('.stop li').removeClass('hover'); }
});

var PageValue = {};


//function btnSearchKeyClick()
//{
//    var keyword = $.trim($('#txtSearchKey').val()); 
//    if (keyword)
//    {
//        if (!validateUtility.isValidBaseString(keyword)) {
//            ZYCLib.UI.MessageBox.Alert("输入的关键字包含非法字符!");
//            return;
//        }

//        window.location.href = stringFormat(PageValue.SearchUrlFormat, encodeURIComponent(keyword));
//        //window.open(stringFormat(PageValue.SearchUrlFormat, encodeURIComponent(keyword)));
//    }
//}



//选择药材品种
function ChooseMB(mCodexID, mCodexName) {
    //转至药材聚合页面
    //var breedUrlFormat = "@Model.BreedUrlFormat";
    window.open(stringFormat(PageValue.BreedUrlFormat, mCodexID));
}

//获取拼音小类
function CallMCodexSubLetter(obj, letter) {

    //切换样式
    $(obj).siblings().removeAttr("class");
    $(obj).parent().siblings().children().removeAttr("class");
    $(obj).parent().siblings().removeAttr("class");
    $(obj).attr("class", "hover");
    $(obj).parent().attr("class", "hover");

    //将拼音小类显示
    $("#showBreedRegion").css("display", "block");

    //服务获取数据
    var serviceProxy = new ServiceProxy();
    var firstLetter = '';
    serviceProxy.getSubLettersByLetter(letter, function (responseData) {
        if (responseData && responseData.ErrorCode == 0 && responseData.Data) {
            var letterHtml = "";
            var letters = responseData.Data.ListLetter;
            for (var i = 0; i < letters.length; i++) {
                var eachLetter = letters[i];
                if (i == 0) {
                    firstLetter = eachLetter;
                    letterHtml += " <a href=\"javascript:void(0);\" onclick=\"CallMCodexByLetter('" + eachLetter + "');\"  class=\"stwoa\" >" + eachLetter + "</a> ";
                } else {
                    letterHtml += " <a href=\"javascript:void(0);\" onclick=\"CallMCodexByLetter('" + eachLetter + "');\"  class=\"stwoa\" >" + eachLetter + "</a> ";
                }
            }

            $("#divMCodexSubLetters").html(letterHtml);
            //显示第一个字母下药材项目
            CallMCodexByLetter(firstLetter);
        }
    });
}

//获取拼音对应的所有品名
function CallMCodexByLetter(letter) {
    //将拼音小类显示
    //服务获取数据
    var serviceProxy = new ServiceProxy();
    serviceProxy.getMCodexsByLetter(letter, 0, function (responseData) {
        if (responseData && responseData.ErrorCode == 0 && responseData.Data) {
            var codexHtml = "";
            var codexs = responseData.Data;
            for (var i = 0; i < codexs.length; i++) {
                var eachCodex = codexs[i];
                if (i == 0) {
                    codexHtml += "<a  href=\"javascript:void(0);\" onclick=\"ChooseMB(" + eachCodex.MBID + ", '" + eachCodex.MName + "');\" class=\"stwoa\" >" + eachCodex.MName + "</a>  ";
                } else {
                    codexHtml += "<a  href=\"javascript:void(0);\" onclick=\"ChooseMB(" + eachCodex.MBID + ", '" + eachCodex.MName + "');\" class=\"stwoa\" >" + eachCodex.MName + "</a>  ";
                }
            }
            $("#divPinyinMCodex").html(codexHtml);
        }
    });
}

//tabs
$(document).ready(function () {
    $('.door li').mouseenter(function () {
        var $this = $(this);
        $this.addClass('hover').siblings().removeClass('hover');
        $('#' + $this.parent().prop('id') + 'Con').children().eq($this.index()).removeClass('none').siblings().addClass('none');
    });
})


